from matplotlib import pyplot as plt
from matplotlib.pyplot import MultipleLocator
import argparse
import os
from math import log10

TARGET_DATA_ALL_SETS = ['7K7K_100w_20210806', '178_100w_20210806', 'Dodonew_100w_20210806',
                        'Tianya_100w_20210806', '17173_100w_20210806', 'Myheritage_100w_20210806',
                        'Twitter_100w_20210806', 'Rockyou_100w_20210806', 'Webhost_100w_20210806', '8Fit_100w_20210806',
                        'DE3_100w_20210806', 'FR1_100w_20210806', 'FR5_100w_20210806']

TRAINING_DATA_SETS = ['CSDN_100w_20210806', 'GMAIL_100w_20210806', 'EYEEM_100w_20210806', 'FR0_100w_20210806']
#TRAINING_DATA_SETS = ['GMAIL_100w_20210806']

MC_FILE_ROOT = os.path.join('..', '..', 'CommonFiles', 'SemanticMidFiles', 'MonteCarloEvaluation', 'Baseline')
BASELINE_MC_SEMANTIC_DICT = {}
BASELINE_MC_FLA_DICT = {}

RA_FILE_ROOT = os.path.join('..', '..', 'CommonFiles', 'Evaluations', 'CoverageRateCalculation', '2022-07')
OUT_FILE_ROOT = os.path.join('..', '..', 'CommonFiles', 'Evaluations', 'CoverageRateCalculation', 'Figures')

BASELINE_RA_NAME_MAP_DICT = {}
BASELINE_RA_NAME_MAP_DICT['CSDN_100w_20210806'] = 'CSDN-100w'
BASELINE_RA_NAME_MAP_DICT['GMAIL_100w_20210806'] = 'GMAIL-100w'
BASELINE_RA_NAME_MAP_DICT['EYEEM_100w_20210806'] = 'EYEEM-100w'
BASELINE_RA_NAME_MAP_DICT['FR0_100w_20210806'] = 'FR0-100w'

BASELINE_RA_NAME_MAP_DICT['7K7K_100w_20210806'] = '7K7K'
BASELINE_RA_NAME_MAP_DICT['178_100w_20210806'] = '178'
BASELINE_RA_NAME_MAP_DICT['Dodonew_100w_20210806'] = 'DODONEW'
BASELINE_RA_NAME_MAP_DICT['Tianya_100w_20210806'] = 'TIANYA'
BASELINE_RA_NAME_MAP_DICT['17173_100w_20210806'] = '17173'
BASELINE_RA_NAME_MAP_DICT['Myheritage_100w_20210806'] = 'MYHERITAGE'
BASELINE_RA_NAME_MAP_DICT['Twitter_100w_20210806'] = 'TWITTER'
BASELINE_RA_NAME_MAP_DICT['Rockyou_100w_20210806'] = 'ROCKYOU'
BASELINE_RA_NAME_MAP_DICT['Webhost_100w_20210806'] = 'WEBHOST'
BASELINE_RA_NAME_MAP_DICT['8Fit_100w_20210806'] = '8FIT'
BASELINE_RA_NAME_MAP_DICT['DE3_100w_20210806'] = 'DE3'
BASELINE_RA_NAME_MAP_DICT['FR1_100w_20210806'] = 'FR1'
BASELINE_RA_NAME_MAP_DICT['FR5_100w_20210806'] = 'FR5'


MC_BOARD_LINE = log10(5e9)

def Init_mc_semantic_baseline():
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_7K7K_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_178_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_Dodonew_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_Tianya_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_17173_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_Myheritage_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_Twitter_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_Rockyou_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_Webhost_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_8Fit_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_DE3_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_FR1_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['CSDN_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_CSDN_Baseline', 'mc_final_data',
                     'mc_evaluation_CSDN_100w_20210806_to_FR5_100w_20210806')


    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_7K7K_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_178_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_Dodonew_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_Tianya_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_17173_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_Myheritage_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_Twitter_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_Rockyou_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_Webhost_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_8Fit_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_DE3_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_FR1_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['GMAIL_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_GMAIL_Baseline', 'mc_final_data', 'mc_evaluation_GMAIL_100w_20210806_to_FR5_100w_20210806')


    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_7K7K_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_178_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_Dodonew_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_Tianya_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_17173_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_Myheritage_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_Twitter_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_Rockyou_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_Webhost_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_8Fit_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_DE3_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_FR1_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['EYEEM_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_EYEEM_Baseline', 'mc_final_data', 'mc_evaluation_EYEEM_100w_20210806_to_FR5_100w_20210806')


    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_7K7K_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_178_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_Dodonew_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_Tianya_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_17173_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_Myheritage_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_Twitter_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_Rockyou_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_Webhost_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_8Fit_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_DE3_100w_20210806')

    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_FR1_100w_20210806')
    BASELINE_MC_SEMANTIC_DICT['FR0_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'Semantic_MonteCarlo_FR0_Baseline', 'mc_final_data', 'mc_evaluation_FR0_100w_20210806_to_FR5_100w_20210806')


def Init_mc_fla_baseline():
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_7k7k_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_178_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_dodonew_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_tianya_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_17173_data.txt')

    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_myheritage_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_twitter_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_rockyou_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_webhost_data.txt')

    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_8fit_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_de3_data.txt')

    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_fr1_data.txt')
    BASELINE_MC_FLA_DICT['CSDN_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_CSDN_Baseline', 'fla_fr5_data.txt')


    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_7k7k_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_178_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_dodonew_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_tianya_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_17173_data.txt')

    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_myheritage_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_twitter_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_rockyou_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_webhost_data.txt')

    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_8fit_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_de3_data.txt')

    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_fr1_data.txt')
    BASELINE_MC_FLA_DICT['GMAIL_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_GMAIL_Baseline', 'fla_fr5_data.txt')


    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_7k7k_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_178_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_dodonew_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_tianya_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_17173_data.txt')

    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_myheritage_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_twitter_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_rockyou_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_webhost_data.txt')

    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_8fit_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_de3_data.txt')

    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_fr1_data.txt')
    BASELINE_MC_FLA_DICT['EYEEM_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_EYEEM_Baseline', 'fla_fr5_data.txt')


    BASELINE_MC_FLA_DICT['FR0_100w_20210806_7K7K_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_7k7k_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_178_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_178_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_Dodonew_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_dodonew_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_Tianya_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_tianya_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_17173_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_17173_data.txt')

    BASELINE_MC_FLA_DICT['FR0_100w_20210806_Myheritage_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_myheritage_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_Twitter_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_twitter_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_Rockyou_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_rockyou_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_Webhost_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_webhost_data.txt')

    BASELINE_MC_FLA_DICT['FR0_100w_20210806_8Fit_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_8fit_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_DE3_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_de3_data.txt')

    BASELINE_MC_FLA_DICT['FR0_100w_20210806_FR1_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_fr1_data.txt')
    BASELINE_MC_FLA_DICT['FR0_100w_20210806_FR5_100w_20210806'] = \
        os.path.join(MC_FILE_ROOT, 'FLA_MonteCarlo_FR0_Baseline', 'fla_fr5_data.txt')


def Read_data_from_monte_carlo(input_path):
    with open(input_path, 'r', encoding='utf-8') as inf:
        scaleList = [0]
        allCoverageList = [0]
        one_line = inf.readline()
        while one_line != '':
            temp_line = one_line.strip('\n')
            if temp_line != '':
                temp_list = temp_line.split('\t')
                this_scale = float(temp_list[3])
                this_all_coverage = float(temp_list[1])
                if this_scale > MC_BOARD_LINE:
                    scaleList.append(this_scale)
                    allCoverageList.append(this_all_coverage)
            one_line = inf.readline()
    return [scaleList, allCoverageList]

def Read_data_from_real_attack(input_path):
    with open(input_path, 'r', encoding='utf-8') as inf:
        scaleList = [0]
        allCoverageList = [0]
        one_line = inf.readline()
        one_line = inf.readline()
        while one_line != '':
            temp_line = one_line.strip('\n')
            if temp_line != '':
                temp_list = temp_line.split('\t')
                this_scale = log10(float(temp_list[0]))
                this_all_coverage = float(temp_list[3])
                scaleList.append(this_scale)
                allCoverageList.append(this_all_coverage)
            one_line = inf.readline()
    return [scaleList, allCoverageList]

def Draw_mix_results(fla_mc_file_path, fla_ra_file_path, semantic_mc_file_path, semantic_ra_file_path, output_path, title):

    fla_mc_list = Read_data_from_monte_carlo(fla_mc_file_path)
    fla_ra_list = Read_data_from_real_attack(fla_ra_file_path)

    semantic_mc_list = Read_data_from_monte_carlo(semantic_mc_file_path)
    semantic_ra_list = Read_data_from_real_attack(semantic_ra_file_path)

    plt.close('all')
    plt.figure(figsize=(20, 15))
    x_major_locator = MultipleLocator(1)
    y_major_locator = MultipleLocator(0.2)
    ax = plt.gca()
    ax.xaxis.set_major_locator(x_major_locator)
    ax.yaxis.set_major_locator(y_major_locator)

    plt.xlim(-0.4, 20.44)
    plt.ylim(-0.04, 1.04)

    plt.plot(fla_mc_list[0][1:], fla_mc_list[1][1:], color='red', linewidth=2.0, linestyle='--', label='fla-monte-carlo')
    plt.plot(fla_ra_list[0], fla_ra_list[1], color='red', linewidth=2.0, linestyle='-', label='fla-real-attack')

    plt.plot(semantic_mc_list[0][1:], semantic_mc_list[1][1:], color='blue', linewidth=2.0, linestyle='--', label='se#pcfg-monte-carlo')
    plt.plot(semantic_ra_list[0], semantic_ra_list[1], color='blue', linewidth=2.0, linestyle='-', label='se#pcfg-real-attack')


    #if baseline_semantic_path != '':
    #    baseline_semantic_data_list = Read_data_from_monte_carlo(baseline_semantic_path)
    #    plt.plot(baseline_semantic_data_list[0], baseline_semantic_data_list[1], color='black', linewidth=1.0,
    #             linestyle='--', label='baseline-se#pcfg')

    #if baseline_fla_path != '':
    #    baseline_fla_data_list = Read_data_from_monte_carlo(baseline_fla_path)
    #    plt.plot(baseline_fla_data_list[0], baseline_fla_data_list[1], color='black', linewidth=1.0, linestyle='-',
    #             label='baseline-fla')

    #x1 = [9, 9]
    #y1 = [0.0, 1.0]

    #x2 = [9.5, 9.5]
    #y2 = [0.0, 1.0]

    #x3 = [10, 10]
    #y3 = [0.0, 1.0]

    #plt.plot(x1, y1, color='gray', linewidth=1.0, linestyle='--')
    #plt.plot(x2, y2, color='gray', linewidth=1.0, linestyle='--')
    #plt.plot(x3, y3, color='gray', linewidth=1.0, linestyle='--')

    plt.legend()
    plt.title(title)
    plt.savefig(output_path)
    plt.close('all')

def main():
    for train in TRAINING_DATA_SETS:
        for target in TARGET_DATA_ALL_SETS:
            dict_key = '%s_%s' % (train, target)
            train_alias = BASELINE_RA_NAME_MAP_DICT[train]
            target_alias = BASELINE_RA_NAME_MAP_DICT[target]
            fla_mc_file_path = BASELINE_MC_FLA_DICT[dict_key]
            fla_ra_file_path = os.path.join(RA_FILE_ROOT, 'FLA', 'AttackRecord-%s-%s-NOTRIM-FLA.txt' % (train_alias, target_alias))

            semantic_mc_file_path = BASELINE_MC_SEMANTIC_DICT[dict_key]
            semantic_ra_file_path = os.path.join(RA_FILE_ROOT, 'SEMANTIC', 'AttackRecord-%s-%s-NOTRIM-SEMANTIC.txt' % (train_alias, target_alias))

            output_path = os.path.join(OUT_FILE_ROOT, '%s-%s.png' % (train, target))

            title = 'CoverageRate Comparison Between %s attacking %s' % (train, target)

            Draw_mix_results(fla_mc_file_path, fla_ra_file_path, semantic_mc_file_path, semantic_ra_file_path, output_path, title)


if __name__ == '__main__':
    Init_mc_fla_baseline()
    Init_mc_semantic_baseline()
    main()
